home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: bcarh8ab.bnr.ca!CompStar!tzinck
- From: tzinck@bnr.ca
- Subject: embedded strtok() calls on different strings?
- Originator: tzinck@bcarhb35
- Message-ID: <DMGrn7.1Bx0@CompStar.bnr.ca>
- Sender: tzinck@bnr.ca (Thomas Zinck)
- Date: Thu, 8 Feb 1996 15:42:43 GMT
- Nntp-Posting-Host: bcarhb35
- Organization: Bell-Northern Research Ltd.
-
-
- Hello.
-
-
- I want to do the following:
-
-
- char *string1="This is string one";
- char *string2="This is string two";
-
- void *vp1;
- void *vp2;
-
- vp1 = strtok(string1," ");
-
- while (vp1 != NULL){
- printf("Tok1 = %s\n", (char *) vp1);
-
- vp2 = strtok(string2," ");
- while (vp2!=NULL){
- printf("Tok2 = %s\n", (char *) vp2);
- vp2 = strtok(NULL, " ");
- }
-
- vp1 = strtok(NULL, " ");
- }
-
- But the output is :
- Tok1 = This
- Tok2 = This
- Tok2 = is
- Tok2 = string
- Tok2 = two
-
-
- as vp1 gets corrupted. Any thoughts ?
-
- -Tom
-
-
-